/*
	implementation of spu driver and its functions
	mechanism: - main is never exiting loop, it grabs jobs by polling and locking the jobs from PPU job queue (1 shared by all SPUs)
			  - each jobs have a certain order of data to be transferred to LS
				- can have dependent jobs to call next, so a certain order is guaranteed without having the need to join or wait on some sync mechanism
				- each job can have multiple input/output packets (memory locations must not depend on the previous jobs)
				- for all kind of callbacks, check job state variable first, this is sync't against output DMA
				- stack when entered main is 752 bytes below the top address -> temp storage
				- it copies the job info block to local store, processes it by dma in the input memory mapping, job code and data 
				- it starts the job by calling the Execute function (always the entry point) by passing the pointer to the parameter area 
	polling behavior:
				- SPU ID0 initially polls with a high rate, the others wait for an event
				- once the pull pointer has been locked, the polling rate is set to high and no further locks are issued
				- if a SPU sees a locked pulling pointer not locked by itself, it resets to a slow polling rate
				- once a job has been fetched, the next SPU (SPU with ID 0 -> SPU with ID 1 and so on) is signaled to start polling
				- once a SPU has finished processing a job chain, the next SPU is signaled to enter wait state
				  (because it does itself change to polling state), the polling frequency is reseted to high

	loops:- each job can have >= 1 packets which are basically consecutive function calls
					- cache is flushed after all have been finished
				- if a job runs via a producer / consumer queue, each packet flushes the cache
					- it cannot have the inner loop packets as above in this mode

	memory layout:

	The LS memory map is organized as follows:
	[TOP Address = 0]
		SPUDriver including Cache
		Page directory
		per Job:
			Info packet (SInfoBlock)
			job function code and data
			parameter area (input into PFNEXECUTE)		
			memory transferred via DMA list
		Stack (at 752 below top)
		384 bytes Initial Loader / 4 * 128 byte static areas for copying stuff here
	[BOTTOM Address = scLSSize]
	
*/ 
#if !defined(__SPU__) && !defined(PS3)
#include "StdAfx.h"
#endif














































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































